home *** CD-ROM | disk | FTP | other *** search
- ; CLOCK.ASM
- ;
- ; Author: M. Steven Baker
- ; Date: September 8, 1988
- ;
- ; clock() routine for SVS C (only)
- ;
- ;
- ;; C CODE TO RUN THIS:
- ;; extern long clock();
- ;
- ; Written for the SVS assembler (ASM68K.E20)
- ; by M. Steven Baker (Technical Editor -- Programmer's Journal)
- ;
- ; note: since dumb SVS assembler doesn't support
- ; EXTB.L D0
- ; we use
- ; ANDI #$FF,D0
- ; EXT.L D0
- ;
- ;
- global clock
- ;
- ; return time in HH:MM:SS format
- ;
- clock MOVEM.L D2,-(SP) ; save D2
- MOVEQ #28,D0 ; GET TIME
- TRAP #14 ; D0=HH:MM:SS:xx
- MOVE.L D0,D1 ; SAVE REGISTER
- SWAP D0 ; get hour to low word
- ASR.W #8,D0 ; SHIFT IN hour
- EXT.L D0 ; extend to a long word
- MOVEQ #60,D2 ; multiply by 60 minutes
- MULU.W D0,D2 ; multiply and save it in D2
- ;
- MOVE.L D1,D0 ; now get minutes
- SWAP D0 ; INTO LOW WORD
- ANDI #$FF,D0 ; screen out all but low byte
- EXT.L D0 ; extend to a long word
- ADD.L D0,D2 ; add minutes to D2
- MOVEQ #60,D0
- MULU.W D0,D2 ; now convert to seconds
- ;
- MOVE.L D1,D0 ; now get seconds
- ASR.W #8,D0 ; SHIFT seconds into low byte
- EXT.L D0 ; extend to a long word
- ADD.L D0,D2 ; add in seconds
- ;now convert to 1/100s of seconds
- MOVE.L D2,D0 ; save x1
- ASL.L #2,D2 ; x 4
- ADD.L D0,D2 ; x 5
- MOVE.L D2,D0 ; and save x5
- ASL.L #2,D0 ; x 20
- ADD.L D2,D0 ; x 25
- ASL.L #2,D0 ; x 100
- ;
- ; now get 1/100 seconds
- ANDI #$FF,D1 ; screen out all but low byte
- EXT.L D1 ; extend to a long word
- ADD.L D1,D0 ; add into D0
- MOVEM.L (SP)+,D2
-
- RTS ; just return for 2.8
- ;
- ; RTD #16 ; return and deallocate for FORTRAN 2.6
- ;
- END
-